<template>
  <div>
    <index-chart v-if="indexStyle==1"></index-chart>
    <index-bdc v-if="indexStyle==2"></index-bdc>
    <index-task v-if="indexStyle==3"></index-task>

    <div style="width: 100%;text-align: right;margin-top: 20px" v-if="sfxs">
      请选择首页样式：
      <a-radio-group v-model="indexStyle">
        <a-radio :value="1">统计图表</a-radio>
        <a-radio :value="2">统计图表2</a-radio>
        <a-radio :value="3">任务表格</a-radio>
      </a-radio-group>
    </div>
  </div>

  <!--

  <div style="font-weight: 600; text-align: center;margin-top: 50px;">
    <span style="color: tomato; font-size: 24px; ">{{ date | formatDate }}</span>
    <br/><br/>

    <div style="width: 100%;text-align: right;margin-top: 20px">
      入春才七日，离家已二年。<br/>
      人归落雁后，思发在花前。<br/>
    </div>
  </div>

  -->

</template>

<script>
import IndexChart from './IndexChart'
import IndexTask from './IndexTask'
import IndexBdc from './IndexBdc'

var padDate = function (value) {
  return value < 10 ? '0' + value : value
}
export default {
  name: 'Analysis',
  components: {
    IndexChart,
    IndexTask,
    IndexBdc
  },
  data() {
    return {
      sfxs: false,
      indexStyle: 2,
      date: new Date()
    }
  },
  filters: {
    // 设置一个函数来进行过滤
    formatDate: function (value) {
      var date = new Date(value)
      var year = date.getFullYear()
      var month = padDate(date.getMonth() + 1)
      var day = padDate(date.getDay())
      var hours = padDate(date.getHours())
      var minutes = padDate(date.getMinutes())
      var seconds = padDate(date.getSeconds())
      // 整理并返回
      return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds
    }
  },
  created() {

  },
  methods: {},
  mounted() {
    // 创建定时器更新最新的时间
    var _this = this
    this.timeId = setInterval(function () {
      _this.date = new Date()
    }, 1000)
  },
  beforeDestroy: function () {
    // 实例销毁前青出于定时器
    if (this.timer) {
      clearInterval(this.timer)
    }
  }
}
</script>
